<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>查看物流</title>
    <link rel="stylesheet" href="./css/style.css">
    <link rel="stylesheet" href="./css/lookLogistics.css">
    <style>
    body, html{font-family: PingFangSC-Regular, sans-serif;}
    </style>
</head>

<body>
    <div class="lookLogistics">
        <div class="line"></div>
        <div class="put_gooods_box">
            <div class="put_gooods">
                <div class="put_left">收货人: <span class="receiver"></span></div>
                <div class="put_right"><span class="receiver_mobile"></span></div>
            </div>
            <div class="put_gooods bor_no">
                <div class="put_left">收货地址: <span class="receiver_address"></span></div>
            </div>
        </div>
        <div class="line"></div>
        <div class="put_gooods_box">
            <div class="put_gooods">
                <div class="put_left"><span class="express_company"></span></div>
                <div class="put_right"><span class="express_no"></span></div>
            </div>
            <div class="put_gooods bor_no">
                <div class="put_left">官方电话</div>
                <div class="put_right blue_color"><span class="express_kefu_phone"></span></div>
            </div>
        </div>
        <div class="line"></div>
        <div class="logistics_list">
<!--             <div class="logistics_item">
                <div class="logistics_status">已签收</div>
                <div class="logistics_time">2018.01.19 22:13</div>
                <div class="logistics_desc">[自提柜]签收人凭取货码签收。感谢使用北京荣丰2008小区丰巢[自提柜]，期待再次为您服务。</div>
            </div>
            <div class="logistics_item">
                <div class="logistics_status">待取件</div>
                <div class="logistics_time">2018.01.19 20:28</div>
                <div class="logistics_desc">[自提柜]您的快件已被北京荣丰2008小区丰巢[自提柜]代收，请及时取件。有问题请联系派件员 13520439482</div>
            </div>
            <div class="logistics_item">
                    <div class="logistics_time logistics_time_yuan">2018.01.19 20:28</div>
                    <div class="logistics_desc">[自提柜]您的快件已被北京荣丰2008小区丰巢[自提柜]代收，请及时取件。有问题请联系派件员 13520439482</div>
                </div>
            <div class="logistics_item">
                <div class="logistics_status">运输中</div>
                <div class="logistics_time">2018.01.19 20:28</div>
                <div class="logistics_desc">[自提柜]您的快件已被北京荣丰2008小区丰巢[自提柜]代收，请及时取件。有问题请联系派件员 13520439482</div>
            </div>
            <div class="logistics_item">
                <div class="logistics_status">已发货</div>
                <div class="logistics_time">2018.01.19 20:28</div>
                <div class="logistics_desc">[自提柜]您的快件已被北京荣丰2008小区丰巢[自提柜]代收，请及时取件。有问题请联系派件员 13520439482</div>
            </div> -->
        </div>
    </div>
</body>

<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js">
</script>

<script type="text/javascript">
$(function () {
    (function ($) {
                $.getUrlParam = function (name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                    var r = window.location.search.substr(1).match(reg);
                    if (r != null) return unescape(r[2]); return null;
                }

                $.render_block_item = function(block){
                    var s = '<div class="warehouse_item">' + 
                                '<div class="en_code">' + block.unique_code + '</div>' + 
                                '<div class="warehouse_detail">' +
                                    '<div class="day">存仓天数: ' + block.days + '天</div>' +
                                    '<div class="detailed">明细&nbsp;&nbsp;' + 
                                        '<img src="./image/chevron_right.png" alt="">' +
                                    '</div>' +
                                '</div>' + 
                            '</div>';
                    return s;
                }

                $.render_express_data_item = function(item){
                    var s = '<div class="logistics_item">' +
                            '<div class="logistics_status">' + item.location + '</div>' + 
                            '<div class="logistics_time">' + item.ftime + '</div>' + 
                            '<div class="logistics_desc">' + item.context + '</div>' + 
                            '</div>';
                    return s;
                }

    })(jQuery);

    var token =$.getUrlParam('token');
    var id = $.getUrlParam('id');
    var host = $.getUrlParam('host');
    var protocol = $.getUrlParam('protocol');
    $.support.cors = true;

    $.ajax({
        type: 'GET',
        url: protocol + '://' + host +'/tea-repo/users/' + id + '/takeout/detail',
        contentType: 'application/json',
        withCredentials: true,
        dataType: 'json',
        headers: {
            Authorization: 'JWT '+token,
        },
        success: function(data){
            $(".receiver").html(data.address_name);
            $(".receiver_mobile").html(data.address_mobile);
            $(".receiver_address").html(data.address_full_address);
            if (data.express_company != "" && data.express_company != null){
                $(".express_company").html(data.express_company);
            }else{
                //快递单号
                $(".express_company").html("快递单号");
            }

            $(".express_no").html(data.express_no);
            $(".express_kefu_phone").html(data.express_kefu_phone);
            for (var i=0; i<data.express_info.data.length; i++){
                var item = data.express_info.data[i];
                $(".logistics_list").append($.render_express_data_item(item));
            }
        }
    })

    // var data = {
    //     "count": 1,
    //     "items": [
    //         {
    //             "id": "88732a8ceab14b249cdbc2ed3412d4b7",
    //             "unique_code": "T1WR10WD12017D15-99",
    //             "repo_id": "55b78c67028648e689dc273e928de72c",
    //             "repo_name": "云南仓",
    //             "repo_price_per_100g_1d": 250.0,
    //             "days": 6,
    //             "procedure_amount": 0.0,
    //             "logistics_amount": 12
    //         }
    //     ],
    //     "price_amount": 679.0,
    //     "repo_amount": 3000.0,
    //     "repo_real_pay_amount": 3000.0,
    //     "repo_preferential_amount": 0.0,
    //     "logistics_amount": 20.0,
    //     "logistics_preferential_amount": 0.0,
    //     "logistics_real_pay_amount": 20.0,
    //     "total_amount": 3020.0,
    //     "trade_datetime": "2018.03.06 03.06",
    //     "payment_method": "",
    //     "payment_method_map": {
    //         "ALI": "支付宝",
    //         "WEIXIN": "微信"
    //     },
    //     "address_name": "刘枫",
    //     "address_mobile": "13311208163",
    //     "address_full_address": "北京天安门南20公里路南6号",
    //     "package_count": 1,
    //     "package": [{
    //            "id": id,
    //            "name": "MINI茶-四季包装.春",
    //            "price": 59,
    //            "avatar": "",
    //            "count": 1
    //     }],
    //     "express_company": "中通快递",
    //     "express_no": "479542124103",
    //     "express_kefu_phone": "95533",
    //     "express_info": 
    //         {
    //         "nu": "479542124103",
    //         "com": "zhongtong",
    //         "data": [
    //             {
    //                 "time": "2018-02-26 12:56:36",
    //                 "ftime": "2018-02-26 12:56:36",
    //                 "context": "[北京市] [北京崇文]的派件已签收 感谢使用中通快递,期待再次为您服务!",
    //                 "location": "北京崇文"
    //             },
    //             {
    //                 "time": "2018-02-26 09:18:05",
    //                 "ftime": "2018-02-26 09:18:05",
    //                 "context": "[北京市] 快件已到达[北京崇文],业务员王志伟正在第1次派件 电话:13370117072 请保持电话畅通、耐心等待",
    //                 "location": "北京崇文"
    //             },
    //             {
    //                 "time": "2018-02-25 16:05:35",
    //                 "ftime": "2018-02-25 16:05:35",
    //                 "context": "[北京市] 快件离开 [北京]已发往[北京崇文]",
    //                 "location": "北京"
    //             },
    //             {
    //                 "time": "2018-02-25 15:43:08",
    //                 "ftime": "2018-02-25 15:43:08",
    //                 "context": "[北京市] 快件到达 [北京]",
    //                 "location": "北京"
    //             },
    //             {
    //                 "time": "2018-02-25 01:37:02",
    //                 "ftime": "2018-02-25 01:37:02",
    //                 "context": "[漯河市] 快件离开 [漯河中转]已发往[北京]",
    //                 "location": "漯河中转"
    //             },
    //             {
    //                 "time": "2018-02-25 01:35:20",
    //                 "ftime": "2018-02-25 01:35:20",
    //                 "context": "[漯河市] 快件到达 [漯河中转]",
    //                 "location": "漯河中转"
    //             },
    //             {
    //                 "time": "2018-02-24 19:10:15",
    //                 "ftime": "2018-02-24 19:10:15",
    //                 "context": "[商丘市] 快件离开 [商丘]已发往[北京]",
    //                 "location": "商丘"
    //             },
    //             {
    //                 "time": "2018-02-24 09:13:19",
    //                 "ftime": "2018-02-24 09:13:19",
    //                 "context": "[商丘市] [商丘]的商丘市场部已收件 电话:15237059688",
    //                 "location": "商丘"
    //             }
    //         ],
    //         "state": "3",
    //         "status": "200",
    //         "ischeck": "1",
    //         "message": "ok",
    //         "condition": "F00"
    //     }
    // };
    // $(".receiver").html(data.address_name);
    // $(".receiver_mobile").html(data.address_mobile);
    // $(".receiver_address").html(data.address_full_address);
    // $(".express_company").html(data.express_company);
    // $(".express_no").html(data.express_no);
    // $(".express_kefu_phone").html(data.express_kefu_phone);
    // for (var i=0; i<data.express_info.data.length; i++){
    //     var item = data.express_info.data[i];
    //     $(".logistics_list").append($.render_express_data_item(item));
    // }

})
</script>

</html>